#!/bin/sh
openssl x509 -req -days 3650 -in sdlpal.csr -out sdlpal.crt -signkey sdlpal.key -extfile sdlpal.req.cfg -extensions extensions
openssl pkcs12 -in sdlpal.crt -inkey sdlpal.key -out ../winrt/SDLPal.UWP/SDLPal_TemporaryKey.pfx -export
thumbprint=$(openssl pkcs12 -in ../winrt/SDLPal.UWP/SDLPal_TemporaryKey.pfx -passin pass:"" -passout pass:"" | openssl x509 -noout -fingerprint |  awk -F'=' '{ print $2 };' | tr -d ':')
sed -i "s@<PackageCertificateThumbprint>[0-9a-fA-F]*</PackageCertificateThumbprint>@<PackageCertificateThumbprint>$thumbprint</PackageCertificateThumbprint>@g" ../winrt/SDLPal.UWP/SDLPal.UWP.vcxproj
